package com.labuser;

import java.applet.AppletContext;

import com.databasefunction.AllDBFunction;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class LabUserFormAction extends ActionSupport{
	private String barcode,dmgseed,sandsillica,moisture;
	
	
	public String getBarcode() {
		return barcode;
	}

	public void setBarcode(String barcode) {
		this.barcode = barcode;
	}

	public String getDmgseed() {
		return dmgseed;
	}

	public void setDmgseed(String dmgseed) {
		this.dmgseed = dmgseed;
	}

	public String getSandsillica() {
		return sandsillica;
	}

	public void setSandsillica(String sandsillica) {
		this.sandsillica = sandsillica;
	}

	public String getMoisture() {
		return moisture;
	}

	public void setMoisture(String moisture) {
		this.moisture = moisture;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		String userrole = (String) ActionContext.getContext().getSession().get("userrole"); 
		if ((null != userrole) && (userrole.equals("labuser") || userrole.equals("admin") || userrole.equals("superadmin"))) {
			
		}else
			return "unauthorised";
		
		String labuser = (String) ActionContext.getContext().getSession().get("username");
		System.out.println("Barcdoe "+barcode);
		AllDBFunction allDBFunction = new AllDBFunction();
		allDBFunction.addValue(barcode.toLowerCase(), dmgseed, sandsillica, moisture, labuser);
		allDBFunction.updateAnalysisTodb(barcode.toLowerCase());
		return "success";
	}
	
	
}
